<?php

abstract class Soul_Db_Driver_Base {

    private $_server = '';
    private $_database = '';
    private $_username = '';
    private $_password = '';
    private $_encode = 'utf8';
    protected $originSql = '';
    protected $boundSql = '';

    protected function __construct($server = NULL, $database = NULL, $username = NULL, $password = NULL){
    	$this->_server = $server;
    	$this->_database = $database;
    	$this->_username = $username;
    	$this->_password = $password;
    }

    public function getServer(){
        return $this->_server;
    }
    public function setServer($value){
        $this->_server = $value;
        return $this;
    }

    public function getDatabase(){
        return $this->_database;
    }
    public function setDatabase($value){
        $this->_database = $value;
        return $this;
    }

    public function getUsername(){
        return $this->_username;
    }
    public function setUsername($value){
        $this->_username = $value;
        return $this;
    }

    public function getPassword(){
        return $this->_password;
    }
    public function setPassword($value){
        $this->_password = $value;
        return $this;
    }

    public function getEncode(){
        return $this->_encode;
    }

    public function setEncode($value){
        $this->_encode = $value;
        return $this;
    }

    public function getBoundSql(){
        return $this->boundSql;
    }

    abstract public function setSql($sql, $params = array());

    abstract public function escapeString(&$value);

    abstract public function isConnected();

    abstract public function isTransaction();

    abstract public function getAffectedRows();
    
    abstract public function fetch();
    
    public function fetchPagination($pageIndex, $pageSize){
    	$offset = ($pageIndex - 1) * $pageSize;
    	return $this->fetchLimit($pageSize, $offset);
    }

    abstract public function fetchLimit($limit, $offset);

    abstract public function connect();

    abstract public function disconnect();

    abstract public function getInsertId();

    abstract public function execute();
    
    abstract public function executeBatch($sql, $split = ';');

    abstract public function beginTransaction();

    abstract public function commitTransaction();

    abstract public function rollbackTransaction();
}